-
Notifications
You must be signed in to change notification settings - Fork 973
Conversation
looks like syncing bookmarks tests are failing so i need to fix those |
I think this is part of a more general issue with appstate performance and we want to batch all updates in the dispatcher to solve some other perf issues. Is there any reason this code can't run in the background page? |
it would be some effort to replace all the calls to |
@diracdeltas the loop that calls the appActions. That part seems like it should be pretty straightforward to move and then I can handle the batching with the appDispatcher stuff I'm working on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know we're discussing moving some of this code around, but i reviewed for the concept of batching.
for ~1k bookmarks it reduces memory consumption which is sweet!
however syncing bookmarks in folders doesn't work, and they end up folderless– comments inline 🎷
js/state/syncUtil.js
Outdated
const parentFolderObjectId = siteProps.parentFolderObjectId | ||
if (parentFolderObjectId && parentFolderObjectId.length > 0) { | ||
siteProps.parentFolderId = | ||
getFolderIdByObjectId(new Immutable.List(parentFolderObjectId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for initial sync, if we apply all bookmarks and folders at once, this will always return null; so folders don't sync.
we could fix this by first applying folders and folderless bookmarks and folders (to ensure correct ordering); then applying foldered bookmarks. see below for more info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ayumi i think there is a general race condition here even if we apply stuff in the right hierarchy order. see #7293 (comment)
js/state/syncUtil.js
Outdated
@@ -194,10 +232,22 @@ module.exports.applySyncRecord = (record) => { | |||
*/ | |||
module.exports.applySyncRecords = (records) => { | |||
if (!records || records.length === 0) { return } | |||
const siteRecords = [] | |||
const otherRecords = [] | |||
records.forEach((record) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bookmark folders:
instead of applying all bookmarks, i think we should first apply all folderless bookmarks and folders, then apply foldered bookmarks. otherwise we won't be able to resolve bookmark.parentFolderObjectId -> parentFolderId, so bookmarks will end up folderless.
bonus points to recursively apply (top level folders/items, then second level, etc) to better ensure folders ids are available when we need them.
@bridiver i tried moving this code to the background script; it didn't beach-ball the browser but it did make the UI non-responsive indefinitely. i think the batching is necessary to solve the perf issue. |
Batching is almost ready
… On Feb 22, 2017, at 8:57 PM, yan ***@***.***> wrote:
@bridiver i tried moving this code to the background script; it didn't beach-ball the browser but it did make the UI non-responsive indefinitely. i think the batching is necessary to solve the perf issue.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
4690c01
to
597483b
Compare
js/state/syncUtil.js
Outdated
appActions.removeSite(siteDetail, tag, true) | ||
} | ||
}) | ||
}, 2000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this has to happen after creation a timeout doesn't seem very safe, or is the timeout just an extra buffer? If so I don't think it's really necessary with the dispatcher changes
597483b
to
00d3186
Compare
js/state/syncUtil.js
Outdated
let existingObjectData | ||
|
||
if (record.action !== writeActions.CREATE) { | ||
// XXX: Is this necessary for CREATEs also? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omitting the existingObject search for CREATES reduces the sync lag significantly, from a minute or so to a couple seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
affirming that existing objects aren't needed – it would have been resolved upstream during get_existing_objects -> resolved_sync_records
updated PR so now it fixes the bookmark folder issue too |
it worked really fast for the then i tested with my special user data which is mildly corrupted (for example some bookmarks include nonexistent parentFolderIds), and it crashed. you can replicate this by editing session-store-1 to change a bookmark's parentFolderId to something bogus, then starting Brave and doing the initial sync upload. it doesn't crash, but it prevents records from being uploaded. in sync.js should
|
@ayumi does that issue exist without this PR? |
@diracdeltas no, it works on master as of d9234b5 |
@ayumi i think its fixed now |
@diracdeltas sweet it works now! |
@@ -485,6 +487,32 @@ const handleAppAction = (action) => { | |||
case appConstants.APP_DATA_URL_COPIED: | |||
nativeImage.copyDataURL(action.dataURL, action.html, action.text) | |||
break | |||
case appConstants.APP_APPLY_SITE_RECORDS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we leave a comment here about refactoring this into a single action with APP_ADD_SITE? When we do that we should probably pull it out of appStore anyway and create a siteReducer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe the comment should go on the action. Either way is fine, just want to capture it in the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
I ran bookmark tests on 7a18689 and found 4 failures 71 passing (3m)
|
@alexwykoff could you try on 9a2b535 ? |
Sure! Here's the latest:
I don't think these are on you, they look like flakey timeouts. |
9a2b535
to
fcb4fc5
Compare
@alexwykoff I think some of those are fixed in #7353 |
fix #7308 fix #7293 fix #7307 Auditors: @ayumi @alexwykoff Test Plan: 1. in about:preferences#sync, choose the 'i have an existing sync code' option. enter in the code words that Alex posted in #testers (starts with 'forsaken') 2. wait for 6000+ bookmarks to appear in the bookmarks toolbar. the browser should not freeze or use excessive memory during the sync. for me it takes about 5 seconds. 3. open about:bookmarks. you should see a bunch of folders with bookmarks, including subfolders.
js/state/syncUtil.js
Outdated
let existingObjectData | ||
|
||
if (record.action !== writeActions.CREATE) { | ||
// XXX: Is this necessary for CREATEs also? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
affirming that existing objects aren't needed – it would have been resolved upstream during get_existing_objects -> resolved_sync_records
syncing tests all fixed now! |
@diracdeltas There is a momentary spike in the CPU usage when bookmarks are sync'd. Brave process's CPU usage goes upto 30% and drops down. It took ~2mins to sync the bookmarks on my machine with a clean profile. |
@srirambv when you say it took ~2 mins, what exactly are you referring to? Did the spike last 2 min? Was it 2 min until they appeared on another device? |
@bridiver The total time to sync was around 2 mins for the bookmarks to shown up on the second device. The CPU spike was momentary around 10 secs (could hear the fan loud and clear), happened initially when the sync code was added and then right before the bookmarks showed up on the second device. |
sync polls every 1 minute, so on average i would expect ~30s for a sync to occur |
If the poll time is 1 minute the average should be closer to 1 minute to sync across devices. 2 minutes would be a theoretical worst case assuming the timers are accurate (which they aren't) and the sync process is instantaneous (which it isn't)
… On Mar 1, 2017, at 11:50 AM, yan ***@***.***> wrote:
sync polls every 1 minute, so on average i would expect ~30s for a sync to occur
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Future versions of this will improve latency with something like SQS
… On Mar 1, 2017, at 11:50 AM, yan ***@***.***> wrote:
sync polls every 1 minute, so on average i would expect ~30s for a sync to occur
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
it sends ~immediately after the state change but the receiver polls every 1min |
fix #7308
Auditors: @ayumi @alexwykoff
Test Plan: